import { Controller, Get, Query } from '@nestjs/common';
import { AppService } from './app.service';
import { Decimal } from 'decimal.js';

@Controller('/d')
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get('/h')
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('/p')
  plus(@Query() obj: number): object {
    const num1 = parseInt(obj['num'], 10);
    const num2 = Number(obj['num']);
    return {
      num1: num1,
      num2: num2,
    };
  }

  @Get('/n')
  number(): object {
    const num = new Decimal('9223372036854775807');
    console.log(num);
    return {
      num: String(num),
    };
  }
}
